#ifndef OMG_TDDS_PUB_COHERENT_SET_HPP_
#define OMG_TDDS_PUB_COHERENT_SET_HPP_

/* Copyright (c) 2009-2010, Real-Time Innovations, Inc.
 * Copyright (c) 2010, Object Management Group, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 * - Neither the names of the above copyright holders nor the names of their
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL A COPYRIGHT HOLDER OR CONTRIBUTOR BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


namespace tdds { namespace pub {

template <typename DELEGATE>
class CoherentSet : public dds::core::Value<DELEGATE> {
public:
    /**
     * This operation requests that the application will begin a
     * coherent set of modifications using DataWriter objects
     * attached to the Publisher. The coherent set will be
     * completed by a matching call to end.  A
     * coherent set is a set of modifications that must be
     * propagated in such a way that they are interpreted at the
     * receivers' side as a consistent set of modifications; that
     * is, the receiver will only be able to access the data after
     * all the modifications in the set are available at the
     * receiver end.  A connectivity change may occur in the middle
     * of a set of coherent changes; for example, the set of
     * partitions used by the Publisher or one of its Subscribers
     * may change, a late-joining DataReader may appear on the
     * network, or a communication failure may occur. In the event
     * that such a change prevents an entity from receiving the
     * entire set of coherent changes, that entity must behave as if
     * it had received none of the set.  These calls can be
     * nested. In that case, the coherent set terminates only with
     * the last call to end.  The support for
     * coherent changes enables a publishing application to change
     * the value of several data-instances that could belong to the
     * same or different topics and have those changes be seen
     * atomically by the readers. This is useful in cases where
     * the values are inter-related. For example, if there are two
     * data instances representing the altitude and velocity
     * vector of the same aircraft and both are changed, it may be
     * useful to communicate those values in a way the reader can
     * see both together; otherwise, it may e.g., erroneously
     * interpret that the aircraft is on a collision course.
     */
    explicit CoherentSet(const dds::pub::Publisher& pub);
    CoherentSet(const CoherentSet& src);

public:
    /**
     * This operation terminates the coherent set initiated by the
     * constructor. If there is no matching call to the constructor,
     * the operation will raise the PreconditionNotMetError.
     */
    void end();         // ends coherent changes explicitly

public:
    /**
     * This operation terminates the coherent set initiated by the
     * constructor.
     */
    ~CoherentSet(); // ends coherent changes implicitly
};

} }

#endif /* OMG_TDDS_PUB_COHERENT_SET_HPP_ */

